"""
文件读写
"""

# 1.打开文件 open(file,mode,encoding)

# file = open("春宵.txt","r",encoding="UTF-8")
# print(file)
# # 2.读取
# print(file.read())
# # 3.关闭
# file.close()
# file =open ("春宵.txt","r",encoding="UTF-8")
# try:
#     print(file.read())
# finally:
#     file.close()
with open("春宵.txt","r",encoding="UTF-8") as file:#try...finally 的简写形式，当with执行完成后无论是否异常都会自动释放资源（自动执行close）
    print(file.read())